package org.opens.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.opens.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/limit")
public class ApiLimitController {

    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "/message1")
    public String message1() {
        return orderService.message("message1");
    }

    @RequestMapping(value = "/message2")
    public String message2() {
        return orderService.message("message2");
    }

    @RequestMapping(value = "/message3")
    @SentinelResource(value = "message3")
    public String message3(
            @RequestParam(value = "name", required = false) String name,
            @RequestParam(value = "age", required = false) Integer age
    ) {
        return orderService.message("message3" + name + age);
    }

}
